<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
  <!ENTITY dc "http://purl.org/dc/elements/1.1/">
  <!ENTITY dcterms "http://purl.org/dc/terms/">
  <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
  <!ENTITY a "http://xmlns.heustics.org/schema/myelin/0.1/">
  <!ENTITY m "http://xmlns.heustics.org/ontology/myelin/0.1/">
]>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:a="http://xmlns.heustics.org/schema/myelin/0.1/"  
  xmlns:l="http://xmlns.heustics.org/schema/i18n/0.1/"
  xmlns:fhttp="http://xmlns.4suite.org/4ss/http"
  xmlns:fcore="http://xmlns.4suite.org/4ss/score"
  xmlns:sess="http://xmlns.heustics.org/xslt/ext/session/0.1/"
  xmlns:o="http://xmlns.heustics.org/schema/myelin/0.1/UserAccount#change-password"
  xmlns:p="http://xmlns.heustics.org/schema/myelin/0.1/AgentAccount#"
  xmlns:u="http://xmlns.heustics.org/schema/myelin/0.1/UserAccount#"
  xmlns:xf="http://www.w3.org/2002/xforms" 
  extension-element-prefixes="fhttp fcore sess"
  exclude-result-prefixes="xsl fhttp fcore sess a l o p u xf"
>   
  <xsl:variable name="o:l10n" select="a:get-l10n('&a;UserAccount#change-password')"/>
  <xsl:variable name="o:titles-l10n" select="$o:l10n/l:context[@name='titles']/*"/> 
    
  <xsl:template match="a:title[@key='change-password']" mode="a:head-content">
    <xsl:call-template name="a:head-title">
      <xsl:with-param name="title" select="$o:titles-l10n[1]"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="a:title[@key='change-password']" mode="a:page-header">
    <xsl:call-template name="a:page-header-title">
      <xsl:with-param name="title" select="$o:titles-l10n[1]"/>
    </xsl:call-template>
  </xsl:template>     
  
  <xsl:template match="a:nick" mode="a:input-show"> 
    <xsl:call-template name="p:nick-input">
      <xsl:with-param name="params-l10n" select="$u:params-l10n"/>
      <xsl:with-param name="hints-l10n" select="$u:hints-l10n"/>
      <xsl:with-param name="read-only" select="1"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="a:form[@mode='main' and @status='commit-success']"> 
    <xsl:param name="config" select="/*/a:config"/>
    <xsl:param name="account" select="/*/a:account"/>  
    <xsl:choose>
      <xsl:when test="$account/@user-id = xf:model/xf:instance/*/@agent-id">
        <xsl:variable name="uri"
          select="a:format-url-ext(
            a:format-url-full-secure(
              a:format-return-root-request(
                'login'
              )
            ),
            'msg','new-password'
          )"/>
        <xsl:choose>
          <xsl:when test="sess:request-logout()">
            <sess:logout-uris
              success-uri="{$uri}"
              failure-uri="{$uri}"/>      
          </xsl:when>
          <xsl:otherwise>
            <fhttp:response-uri
              uri="{$uri}"/>      
          </xsl:otherwise>
        </xsl:choose>        
      </xsl:when>   
      <xsl:otherwise>
        <xsl:call-template name="a:main-editor-form">
          <xsl:with-param name="config" select="$config"/>
          <xsl:with-param name="account" select="$account"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>   
  </xsl:template>
  
</xsl:stylesheet>

